#include "cameraviewwidget.h"
#include "ui_cameraviewwidget.h"
#include "dialog/imagedetaildialog.h"

CameraViewWidget::CameraViewWidget(QWidget *parent)
    : QWidget(parent)
    , m_bHasDetailInformation(false)
    , m_bHasImage(false)
    , ui(new Ui::CameraViewWidget)    
    , m_viewBox(new CameraGraphicsView(this))
{
    ui->setupUi(this);

    ui->ViewBox_widget->layout()->addWidget(m_viewBox);

    m_viewBox->SetImage(QImage(":/image/noimage.jpg"));
}

CameraViewWidget::~CameraViewWidget()
{
    delete ui;
    delete m_viewBox;
}

void CameraViewWidget::ClearBackground(){
    m_bHasImage = false;
    m_viewBox->ClearImage();
}

void CameraViewWidget::SetImageResult(int nRet){
     m_viewBox->SetImageResult(nRet);
}

void CameraViewWidget::SetImage(QImage image){
    m_bHasImage = true;
    m_viewBox->SetImage(image);   
}

void CameraViewWidget::SetInfo(QString info){
    m_viewBox->SetInfo(info);
}

void CameraViewWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(m_bHasDetailInformation && m_bHasImage){
        ImageDetailDialog *pImageDetailDialog = new ImageDetailDialog(this);
        pImageDetailDialog->showMaximized();
        pImageDetailDialog->setModal(true);
        pImageDetailDialog->show();
        pImageDetailDialog->SetImageNum(this->m_nImageNum);
    }
}
